<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<style>
	*{margin:0;padding:0;}
	a{text-decoration:none;}
	.fl-left{float:left;}
	.fl-right{float:right;}
	.cl{clear:both; }
	.mrg-left-5{margin-left:5px;}
	.mrg-left-10{margin-left:10px;}
	.btn{width:80px;height:45px;border-radius:5px;background:red;color:white;border:none;cursor:pointer;}
	.btn:hover {font-size:15px;}
	
	.cotent{width:800px;height:600px;border:1px solid black;margin-top:0px;margin-left:250px;}
	.main{width:100%;height:300px;margin:150px 0px 100px 150px;}
	ul li{list-style:none;margin-top:20px;}
	.titile{font-size:60px;}
	.num{font-size:60px;font-weight:bold;color: red;}
</style>
</head>
<body>
	每<select id="ch" onchange="changTime();">
		<option value="1">1</option>
		<option value="2">2</option>
		<option value="3">3</option>
		<option value="4">4</option>
		<option value="5" selected>5</option>
		<option value="6">6</option>
		<option value="7">7</option>
		<option value="10">10</option>
		<option value="50">50</option>
	</select>秒刷新
	<div class="cotent">
		<h1>现在的时间是：<span class="time" id="time"></span></h1>
		<ul class="main">
			<li><span class="titile">交易金额：</span><span class="num" id="priceCount">54321</span></li>
			<li><span class="titile">订单数量：</span><span class="num" id="orderCount">54321</span></li>
			<li><span class="titile">商品数量：</span><span class="num" id="proCount">54321</span></li>
			<li><span class="titile">用户数量：</span><span class="num" id="userCount">54321</span></li>
		</ul>
	</div>
<script>
	var perTime = 5000;
	var moiter;
	$(function(){
		time();
		getVla();
		setInterval("time()",1000);//1000为1秒钟
		moiter = setInterval("getVla()",perTime);//1000为1秒钟
	})
	function changTime(){
		clearInterval(moiter);
		perTime = $('#ch').val()*1000;
		moiter = setInterval("getVla()",perTime);//1000为1秒钟
	}
	function time(){
		$('#time').html(new Date().pattern("yyyy-MM-dd hh:mm:ss"));
	}
	function getVla(){
		$.ajax({
            type: "POST",
            url: "count/count",
            data: {},
            timeout: 1800000,  //30分钟的超时时间
            async: false,
            success: function(opResult){
            	if('0000'==opResult.respCode){
            		$('#priceCount').html(opResult.returnObj.priceCount);
            		$('#orderCount').html(opResult.returnObj.orderCount);
            		$('#proCount').html(opResult.returnObj.proCount);
            		$('#userCount').html(opResult.returnObj.userCount);
            	}else{
            		alert("加载失败")
            	}
            },
            error:function () {
            	alert('操作失败');
            }
		});
	}
	Date.prototype.pattern=function(fmt) {         
	    var o = {         
	    "M+" : this.getMonth()+1, //月份         
	    "d+" : this.getDate(), //日         
	    "h+" : this.getHours()%12 == 0 ? 12 : this.getHours()%12, //小时         
	    "H+" : this.getHours(), //小时         
	    "m+" : this.getMinutes(), //分         
	    "s+" : this.getSeconds(), //秒         
	    "q+" : Math.floor((this.getMonth()+3)/3), //季度         
	    "S" : this.getMilliseconds() //毫秒         
	    };         
	    var week = {         
	    "0" : "/u65e5",         
	    "1" : "/u4e00",         
	    "2" : "/u4e8c",         
	    "3" : "/u4e09",         
	    "4" : "/u56db",         
	    "5" : "/u4e94",         
	    "6" : "/u516d"        
	    };         
	    if(/(y+)/.test(fmt)){         
	        fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));         
	    }         
	    if(/(E+)/.test(fmt)){         
	        fmt=fmt.replace(RegExp.$1, ((RegExp.$1.length>1) ? (RegExp.$1.length>2 ? "/u661f/u671f" : "/u5468") : "")+week[this.getDay()+""]);         
	    }         
	    for(var k in o){         
	        if(new RegExp("("+ k +")").test(fmt)){         
	            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));         
	        }         
	    }         
	    return fmt;         
	}       
	     
</script>
</body>
</html>